package com.zm.demo.core.leetcode;

import java.util.Random;

/**
 * @author zoum
 * @create 2020/1/14 13:32
 */
public class NumberOfLines {

    public int[] numberOfLines(int[] widths, String S) {

        if (S == null || S.length() == 0){
            return null;
        }

        int[]result = new int[2];
        result[0] = 1;
        for (int i = 0; i < S.length() ; i++) {
            if (widths[S.charAt(i)-'a'] > 100){
                return null;
            }
            while ((widths[S.charAt(i)-'a'] + result[1]) > 100){
                result[1] = 0;
                result[0]++;

            }
            result[1]+=widths[S.charAt(i)-'a'];
        }
        return result;
    }
}
